package com.rdc.dictionary.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.rdc.dictionary.daily.DailyModel;
import com.rdc.dictionary.daily.DailyPresenter;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * @author Soul Mate
 * @file 文件名
 * @brief 对网络地址图片加载为Bitmap
 */

public class ImageAction
{
	public static Bitmap getURLImage(String url) {

		Bitmap bmp = null;

		try {

			URL myUrl = new URL(url);

			// 获得连接
			HttpURLConnection conn = (HttpURLConnection) myUrl.openConnection();


			conn.setDoInput(true);

			conn.connect();


			//获得图片的数据流
			InputStream is = conn.getInputStream();
			//读取图像数据
			bmp = BitmapFactory.decodeStream(is);


			is.close();


		} catch (Exception e)
		{
			e.printStackTrace();
		}



		return bmp;
	}
}
